[StructureMap] Xml configuration or Configuration through code?

Posted by Amith George on Stack Overflow See other posts from Stack Overflow or by Amith George
Published on 2010-02-17T11:22:24Z Indexed on 2010/05/19 9:30 UTC
Read the original article Hit count: 323

I personally like the option to configure StructureMap from C# code. From what I understand, one of the advantages of DI, is that we can easily swap in a new concrete instance. But, if the configuration is defined in code, then the concrete instances are hardcoded in the dll.

So, practically, its as good as having hard coded the dependencies, right? I know, during testing it makes life easier...

My point is, wouldnt it be better to use xml configuration instead? you want to plugin a new concrete instance? simply have your installer overwrite the structuremap.config file with the new one.

So, what is the preferred way to configure StructureMap?

Extra: Am forced to use C# configuration for the time being because I dont know how to pass the connection string to instance. I can write the connectionstring in the config file, but i would like to reuse the connectionstring defined in app.config.

© Stack Overflow or respective owner

Related posts about structuremap

Related posts about dependency-injection